package cn.jinjimi.app.main.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import cn.jinjimi.app.R;
import cn.jinjimi.app.entity.HonorBean;
import cn.jinjimi.app.main.adapter.extend.MyBaseAdapter;

/**
 * Created by Roy
 * Date: 15/9/7
 */
public class HonorListAdapter extends MyBaseAdapter<HonorBean> {

    private Context mContext;

    public HonorListAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        HonorBean item = getItem(position);
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.honor_list_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.imgHonor.setImageURI(Uri.parse(item.getImage_url()));
        holder.tvName.setText(item.getName());
        return convertView;
    }

    static class ViewHolder {
        ImageView imgHonor;
        TextView tvName;

        public ViewHolder(View view) {
            imgHonor = (ImageView) view.findViewById(R.id.img_honor);
            tvName = (TextView) view.findViewById(R.id.tv_name);
        }
    }
}
